
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-05-29
 * Time: 7:59
 */
class CellPhone {
    public String type;
    public int memory;
    public int storage;
    public int price;

    public CellPhone(String type, int memory, int storage, int price) {
        this.type = type;
        this.memory = memory;
        this.storage = storage;
        this.price = price;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CellPhone cellPhone = (CellPhone) o;
        return memory == cellPhone.memory && storage == cellPhone.storage && type.equals(cellPhone.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(type, memory, storage, price);
    }

    @Override
    public String toString() {
        return "CellPhone [" +
                "model:" + type +
                ", memory:" + memory +
                ", storage:" + storage +
                ", price:" + price +
                ']';
    }
}

class Book {
    public String name;
    public Date publishDate;
    public double price;

    public Book(String name, Date publishDate, double price) {
        this.name = name;
        this.publishDate = publishDate;
        this.price = price;
    }

    @Override
    public String toString() {
        return
                "书名:" + name +
                ",定价:" + price;
    }
}
class BookComparatorByPrice implements Comparator<Book> {
    @Override
    public int compare(Book o1, Book o2) {
        if(o1.price != o2.price) {
            return o1.price > o2.price ? 1 : -1;
        } else {
            return o1.name.compareTo(o2.name);
        }
    }
}
class BookComparatorByPubDate implements Comparator<Book> {

    @Override
    public int compare(Book o1, Book o2) {
        return o2.publishDate.compareTo(o1.publishDate);
    }
}
abstract class Student {
    private int ID;
    private String name;
    private String sex;
    private double achievement;

    public Student(int ID, String name, String sex, double achievement) {
        this.ID = ID;
        this.name = name;
        this.sex = sex;
        this.achievement = achievement;
    }

    public double getAchievement() {
        return achievement;
    }

    public void setAchievement(double achievement) {
        this.achievement = achievement;
    }



    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
    public abstract void getGrade();
    public void print(){
        System.out.println("no: " + ID);
        System.out.println("name: " + name);
        System.out.println("sex: " + sex);
    }
}
class CollegeStudent extends Student{

    private String major;
    public CollegeStudent(int ID, String name, String sex, String major, double achievement) {
        super(ID, name, sex, achievement);
        this.major = major;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    @Override
    public void getGrade() {
        double grade = getAchievement();
        if(grade >= 80) {
            System.out.println("A");
        } else if (grade >= 70) {
            System.out.println("B");
        } else if (grade >= 60) {
            System.out.println("C");
        } else if (grade >= 50) {
            System.out.println("D");
        } else {
            System.out.println("E");
        }
    }

    @Override
    public void print() {
        super.print();
        System.out.println("major: " + major);
    }
}
class GraduateStudent extends CollegeStudent {

    @Override
    public void getGrade() {
        double grade = getAchievement();
        if(grade >= 90) {
            System.out.println("A");
        } else if (grade >= 80) {
            System.out.println("B");
        } else if (grade >= 70) {
            System.out.println("C");
        } else if (grade >= 60) {
            System.out.println("D");
        } else {
            System.out.println("E");
        }
    }

    private String teacher;

    public String getTeacher() {
        return teacher;
    }

    public void setTeacher(String teacher) {
        this.teacher = teacher;
    }

    public GraduateStudent(int ID, String name, String sex, String major, String teacher, double achievement) {
        super(ID, name, sex, major, achievement);
        this.teacher = teacher;
    }
    public void doResearch(){
        System.out.println(super.getName() + " is doing research");
    }

    @Override
    public void print() {
        super.print();
        System.out.println("supervisor: " + teacher);
    }
}
interface USB {
    void work();
    void stop();
}
class Mouse implements USB {

    @Override
    public void work() {
        System.out.println("我点点点");
    }

    @Override
    public void stop() {
        System.out.println("我不能点了");
    }
}
class UDisk implements USB {

    @Override
    public void work() {
        System.out.println("我存存存");
    }

    @Override
    public void stop() {
        System.out.println("我走了");
    }
}
public class Main {
    public static void main(String[] args) {
        USB usb1 = new Mouse();
        usb1.work();
        usb1.stop();
        USB[] usbs = new USB[2];
        usbs[1] = usb1;
        usbs[0] = new UDisk();
        for (int i = 0; i < 2; i++) {
            usbs[i].work();
            usbs[i].stop();
        }
    }
    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Student student = new CollegeStudent(scanner.nextInt(), scanner.next(), scanner.next(), scanner.next(), scanner.nextDouble());
        Student student1 = new GraduateStudent(scanner.nextInt(), scanner.next(), scanner.next(), scanner.next(), scanner.next(), scanner.nextDouble());
        student.getGrade();
        student1.getGrade();
    }
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        CellPhone c1 = new CellPhone(sc.next(),sc.nextInt(),sc.nextInt(),sc.nextInt());
        CellPhone c2 = new CellPhone(sc.next(),sc.nextInt(),sc.nextInt(),sc.nextInt());

        System.out.println(c1.equals(c2));
        System.out.println(c1);
        System.out.println(c2);
    }
}
